import 'package:flutter/material.dart';

//ListView列表组件
void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text(
            'Column组件',
          ),
          backgroundColor: Colors.green[100],
        ),
        body: MyHomePage(),
      ),
    );
  }
}

class MyHomePage extends StatelessWidget {
  MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    //Padding组件
    return Container(
      width: double.infinity,
      height: double.infinity,
      color: Colors.yellow,
      child: Column(
      mainAxisAlignment: MainAxisAlignment.spaceEvenly,//主轴的排序方式
      crossAxisAlignment:CrossAxisAlignment.center, //次轴的排序方式  相对于父级元素
      children: [
         IconContainer(Icons.home),
         IconContainer(Icons.search, color: Colors.blue),
         IconContainer(Icons.settings, color: Colors.green), 
      ],
    ),
    );
  }
}

class IconContainer extends StatelessWidget {
  final Color color;
  final IconData icon;
  const IconContainer(this.icon, {super.key, this.color = Colors.red});

  @override
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.center,
      width: 120,
      height: 120,
      color: this.color,
      child: Icon(icon, size: 28, color: Colors.white),
    );
  }
}
